package com.eastfair.imaster.enumeration;

import com.eastfair.annotation.base.BaseEnum;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 业务资源表
 * </p>
 *
 * @author ligang
 * @date 2022-03-10
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "BusinResourceCorrelationTypeEnum", description = "关联身份#{user:用户;exhibitor:展商;project:项目;sponsor:主办-枚举")
public enum BusinResourceCorrelationTypeEnum implements BaseEnum {

    /**
     * USER="用户"
     */
    USER("用户"),
    /**
     * EXHIBITOR="展商"
     */
    EXHIBITOR("展商"),
    /**
     * PROJECT="项目"
     */
    PROJECT("项目"),
    /**
     * SPONSOR="主办"
     */
    SPONSOR("主办"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static BusinResourceCorrelationTypeEnum match(String val, BusinResourceCorrelationTypeEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static BusinResourceCorrelationTypeEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(BusinResourceCorrelationTypeEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "USER,EXHIBITOR,PROJECT,SPONSOR", example = "USER")
    public String getCode() {
        return this.name();
    }

}
